package com.example.cobodynamicproxydemo.interceptors.impl;

import com.example.cobodynamicproxydemo.interceptors.UserApiInterceptor;
import com.example.cobodynamicproxydemo.service.UserApiExecution;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Order(1)
@Slf4j
@Component
public class UserOneApiInterceptor implements UserApiInterceptor {

    @Override
    public Object interceptor(Method method, Object[] args, UserApiExecution next) {
        //  执行请求计数操作......
        //  执行redis计数器操作++
        log.info("[interceptor]执行ONE拦截器: 请求参数: {}", args);
        Object result = next.execute(method, args);
        log.info("[interceptor]执行ONE拦截器完成: 返回结果: {}", result);
        //  返回结果增加操作......
        return result;
    }
}
